import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'

import Layout from '../layout/index.vue'
import {dataRouter} from './modules/data'

export const appMenu: Array<RouteRecordRaw> = [
  {
    path: '',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: '/dashboard',
        component: () => import('@/views/dashboard/index.vue'),
        name: 'Dashboard',
        meta: { title: '首页', icon: 'dashboard', affix: true },
      },
    ],
  },
  {
    path: '/tools',
    component: Layout,
    children: [
      {
        path: 'designer',
        name: 'GraphDesigner',
        component: () => import('@/views/graphDesigner/index.vue'),
        meta: { title: '图谱设计' },
      },
    ],
  },
  {
    path: '/model',
    component: Layout,
    children: [
      {
        path: 'designer',
        name: 'ModelDesigner',
        component: () => import('@/views/model-designer/index.vue'),
        meta: { title: '模型设计' },
      },
    ],
  },
  {
    path: '',
    component: Layout,
    children: [
      {
        path: '/graphView',
        name: 'GraphView',
        component: () => import('@/views/graphView/index.vue'),
        meta: { title: '图谱展示' },
      },
    ],
  },
  {
    path: '/graph',
    component: Layout,
    children: [
      {
        path: 'movie',
        name: 'MovieGraph',
        component: () => import('@/views/graph/movie-graph.vue'),
        meta: { title: '电影图谱' },
      },
    ],
  },
  dataRouter
]

const routes: Array<RouteRecordRaw> = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/index.vue'),
    meta: { title: '登录页' },
  },
  {
    path: '/template',
    name: 'template',
    component: () => import('@/views/template/base.vue'),
  },
  ...appMenu,
  // ...dataRouterMenu,
]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
})

export default router
